package CSDN.hzh22_7.test_2;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Description:
 * @Author: Hanzao
 * @Date: 2022/07/24/15:55
 */
public class third_hzh {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str_0 = scan.nextLine().trim();
        int n = Integer.parseInt(str_0);




        String str_1 = scan.nextLine();
        String[] line_list_1 = str_1.trim().split(" ");
        ArrayList<Integer> arr = new ArrayList<>();
        for(int i = 0; i < line_list_1.length; i++){
            arr.add(Integer.parseInt(line_list_1[i]));
        }


        scan.close();

        ArrayList<Integer> result = solution(n, arr);


        for (int i = 0; i < result.size(); i++){
            System.out.print(result.get(i) + " ");
        }


    }

    public static ArrayList<Integer> solution(int n, ArrayList<Integer> arr){
        ArrayList<Integer> result = new ArrayList<>();

        // TODO: 请在此编写代码
        //错误情况
        if (arr.size() <=0) {
            result.add(0);
            result.add(0);
            return result;
        }

        int left0 = 0;
        int left1 = 0;
        int right = 0;
        long max = arr.get(0);
        long sum = 0;

        for (int i = 0; i < arr.size(); i++) {
            sum += arr.get(i);
            if (sum <= arr.get(i)) { //使用<=还是<呢？
                sum = arr.get(i);
                left0 = i;
            }
            if (sum > max) {
                max = sum;
                left1 = left0;
                right = i;
            }
        }
        //System.out.println("left:" + left1 + " right:" + right + " max:" + max);
        result.add(left1);
        result.add(right);
        return result;
    }
}
